﻿namespace Skymate.Commands
{
    using System.Collections.Generic;
    using System.ComponentModel;

    /// <summary>
    /// 灯色状态
    /// </summary>
    [TypeConverter(typeof(ExpandableObjectConverter))]
    [Description("展开查看灯色状态选项")]
    public class LightColorState
    {
        [DisplayName(@"灯色")]
        [Description("灯色")]
        public List<LightColor> LightColors { get; set; }
        
        public static LightColorState Create(byte[] buffer)
        {
            if (buffer.Length != 12)
            {
                return null;
            }

            var colors = new List<LightColor>();

            foreach (var b in buffer)
            {
                colors.AddRange(LightColorHelper.CreateLightColors(b));
            }

            return new LightColorState() { LightColors = colors };
        }
    }
}